#include <51func.h>
int main(int argc, char *argv[])
{
    pthread_mutexattr_t mutexattr; // 1 为锁属性申请内存
    pthread_mutexattr_init(&mutexattr); // 2 初始化锁属性
    pthread_mutexattr_settype(&mutexattr,PTHREAD_MUTEX_ERRORCHECK); // 3 锁属性设置为检错锁
    pthread_mutex_t mutex;
    pthread_mutex_init(&mutex,&mutexattr); // 4 初始化出来的是检错锁
    
    int ret = pthread_mutex_lock(&mutex);
    THREAD_ERROR_CHECK(ret,"lock1");
    printf("Lock1\n");
    ret = pthread_mutex_lock(&mutex);
    THREAD_ERROR_CHECK(ret,"lock2");
    printf("Lock2\n");
    
    pthread_mutex_unlock(&mutex);
    pthread_mutex_unlock(&mutex);
    return 0;
}

